package com.zy.chapter6

/**
 * @author: zhaoyi
 * @create: 2020-04-27 22:25
 * @description: ${description}
 **/
object Account {

  private var lastNum :Long = 0

  private def newUniqueNum() :Long = {
    lastNum += 1
    lastNum
  }

}

class Account{


  //类和他的伴生对象可以相互访问private的属性
  //他们必须存在同一个源文件
  val id = Account.newUniqueNum()
  private var balance = 0.0D

}
